﻿using System.Collections.Generic;
using System.Collections.Specialized;
using System.Security.Principal;
using Com.FastSearch.SharePoint.BL.SearchManager;

namespace Com.FastSearch.SharePoint.Interfaces
{
    /// <summary>
    /// Defines the interface of the Search Manager, the central point of control for accessing search views
    /// and performing searches.
    /// </summary>
    public interface IESPSearchManager
    {
        /// <summary>
        /// Perform a search using the given settings. The provided WindowsEntity will be passed along,
        /// so that the FAST Security Access Module (SAM) can restrict search results if enabled.
        /// </summary>
        /// <param name="searchSettings">query, search parameters, etc., see <see cref="IESPSearchSettings"/> for details</param>
        /// <param name="windowsIdentity">the user performing the search</param>
        /// <returns>search results</returns>
        IESPSearchResult Search(IESPSearchSettings searchSettings, WindowsIdentity windowsIdentity);
        
        /// <summary>
        /// Get a collection of strings representing the names of all the search views available.
        /// </summary>
        /// <returns>search view names</returns>
        StringCollection GetSearchViews();

        /// <summary>
        /// Get a list of fields that can be used for result sorting (ascending and descending), as well as
        /// rank profiles that can be specified for sorting (only descending, highest ranked results first).
        /// </summary>
        /// <param name="viewName">the name of the search view for which to fetch sortable fields and rank profiles</param>
        /// <returns>a list of <see cref="ISortField"/>s</returns>
        List<ISortField> GetSortableFieldsAndRankProfiles(string viewName);       

        /// <summary>
        /// Return available navigators for a view.
        /// </summary>
        /// <param name="viewName">The view for which to fetch navigators.</param>
        /// <returns>NameValueCollection where internal navigator names are the Names, and the user
        /// friendly display names are the Values. If none are available or an error occures an ampty
        /// NameValueCollection is returned. Never null.</returns>
        IDictionary<string, IESPNavigatorDefinition> GetNavigatorsForView(string viewName);

        /// <summary>
        /// The QRServers string as configured in the Web Application level.
        /// Configured in each web application in: "Site Settings -> Site Collection Administration -> ESP Query Server Connections"
        /// </summary>
        /// <returns>QRServer connection string, on the format "qrserverhost1.domain.com:15100,qrserverhost2.domain.com:15100"</returns>
        /// 
        /*
        string SPWebApplicationQRServersConfig
        {
            get;
            set;
        }
        */
    }
}
